<?php
	session_start();
	require_once('LoginController.php');
	require_once('LoginView.php');
	require_once('LoginHandler.php');
	require_once('Database.php');
	require_once('DBconfig.php');
	require_once('RegisterView.php');
	require_once('RegisterController.php');
	require_once('RegisterHandler.php');
	require_once('NavigationView.php');
	require_once('Validering.php');
	require_once('PageView.php');
	
	class MasterController{
		
		// doControll kollar navigation, om man vill registrera eller logga in
		// och visar beroende på vad url:en visar. 
		public static function doControll(){
			
			$title = "PHP - Tomas";
			$html = null;
			$db = new Database();
			$db->Connect(new DBconfig());
			$pageView = new PageView();
			$navView = new NavigationView();
	
			if($navView->navRegister()){
				$rController = new RegisterController(); 
				$controller = $rController->DoControll($db);
				$html = $pageView->GetHTML($title, $controller);
			}
			else{
				
				$lController = new LoginController();
				$controller = $lController->DoControll($db);
				$html = $pageView->GetHTML($title, $controller);
			}
			
			return $html;
			$db->Close();



		}
	}
		
		echo MasterController::doControll();


